#ifndef NAVIGATIONCONTROLLER_H
#define NAVIGATIONCONTROLLER_H
#include <QObject>
#include <QDebug>
#include <QStackedLayout>
#include  <global.h>

/**
 * @brief The MyNavigationController class
 * 管理页面跳转
 * 全局单例
 */
class MyNavigationController : public QObject
{
    Q_OBJECT
public:
    static MyNavigationController& instance(){
        static MyNavigationController instance;
        return instance;
    }

    MyNavigationController(const MyNavigationController&) = delete;
    void operator = (const MyNavigationController&) = delete;

    void navigateToPage(Route destination);             // 导航路由
    void backToMainPage();                              // 返回主页面

    QStackedLayout * getStackLayout();

private:
    MyNavigationController();

    void init(QWidget *parent = nullptr);               // 初始化

    ~MyNavigationController(){
        qDebug() << "~NavigationController";
        delete this -> stackLayout;
    }


    QStackedLayout *stackLayout;
    QWidget * centralWidget;                            // 中心布局
};

#endif // NAVIGATIONCONTROLLER_H
